<?php
/*
    把css下面对应的文件移动到前端
 * /controller/css/$themer_floder移动到/front/$theme_floder/asset/controller/之下
 * */

/*创建目录*/
function create_folders($dir){
    return is_dir($dir) or (create_folders(dirname($dir)) and mkdir($dir, 0777));
    echo "<br/>目录创建完毕<br/>";
}

/*搜索目录*/
function searchDir($path,&$files){

    if(is_dir($path)){
        $opendir = opendir($path);
        while ($file = readdir($opendir)){
            if($file != '.' && $file != '..'){
                searchDir($path.'/'.$file, $files);
            }
        }
        closedir($opendir);

    }
    if(!is_dir($path)){
//        echo $path.'<br/>';
        $filePathList =explode('/',$path);
        $newDirPath = '../front/'.$filePathList[count($filePathList) - 2].'/asset/css/controller/';
//        echo $newDirPath.'<br/>';
        $newFilePath = $newDirPath.$filePathList[count($filePathList) - 1];
//        echo $newFilePath.'<br/>';

        if(create_folders($newDirPath)){
            //拷贝文件
            copy($path,$newFilePath);
        }

        $files[] = $path;
    }

    echo "<br/>目录搜索完毕<br/>";


}

//得到目录名
function getDir($dir){
    $files = array();
    searchDir($dir, $files);
    return $files;
    echo "<br/>获取目录名<br/>";

}

$filenames = getDir('../../../controller/css');


